<template>
    <div class="container" @click="handleClickImg">
      <div class="wrapper">
        <swiper :options="swiperOptions">
          <swiper-slide v-for="(item,index) of swiper" :key="index">
            <img class="swiper-img" :src="item"/>
          </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
      </div>
    </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'CommonGallary',
  data () {
    return {
      swiper: [],
      swiperOptions: {
        loop: true,
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    getHomeInfo () {
      axios.get('/api/index.json')
        .then(this.getHomeInfoSucc)
    },
    getHomeInfoSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        this.swiper = data.swiperList
      }
      console.log(this.swiper)
    },
    handleClickImg () {
      this.$emit('close')
    }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style lang="stylus" scoped>
// .wrapper >>> .swiper-pagination-bullet-active
//   background: white
  ..container >>> .swiper-pagination
    overflow inherit
  .container
    z-index: 99
    display: flex
    flex-direction: column
    justify-content: center
    position: fixed
    top: 0
    bottom: 0
    left: 0
    right: 0
    background: black
    .wrapper
      background: white
      .swiper-img
        width: 100%
      .swiper-pagination
        color: red
</style>
